package com.class06.advice;

import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.context.annotation.Configuration;
import org.aspectj.lang.JoinPoint;

//@Aspect
@Configuration
public class TestAround {

//    @Around =  @Before +@AfterReturning + @AfterThrowing + @After
    @Around("com.class06.point.TestPointCut.class06PointCut1()")
    public Object testTestAround(JoinPoint joinPoint) {

        Object[] args = joinPoint.getArgs();

        try {
            System.out.println("类似前置通知----->"+ "环绕通知的前置" );
            int j = 10 / 0;
            System.out.println(j);
            int result = 0;
            for (Object arg : args) {
                result += (int) arg;
            }

            System.out.println("类似返回通知----->"+ "环绕通知的返回" + result );
        } catch (Exception e) {
            System.out.println("类似异常通知----->"+ "环绕通知的异常" );
        }finally {
            System.out.println("类似后置通知----->"+ "环绕通知的后置" );
        }

        System.out.println(args[0]);

        return args[0];

    }
}
